package com.ruoyi.delivery.controller;

import java.util.List;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.domain.GarbageRecyclingOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.delivery.service.IGarbageRecyclingOrderService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 垃圾回收订单Controller
 * 
 * @author ruoyi
 * @date 2021-03-29
 */

@Api(tags = "垃圾投递")
@RestController
@RequestMapping("/easyOrder")
public class GarbageRecyclingOrderController extends BaseController
{
    @Autowired
    private IGarbageRecyclingOrderService garbageRecyclingOrderService;

    /**
     * 查询垃圾回收订单列表
     */

    @ApiOperation(value = "查询垃圾回收订单列表",notes = "按条件查询垃圾回收订单列表")
    @ApiImplicitParam(name = "garbageRecyclingOrder", value = "垃圾回收订单详细表", required = false, dataType = "GarbageRecyclingOrder")
    @GetMapping("/list")
    public TableDataInfo list(GarbageRecyclingOrder garbageRecyclingOrder)
    {
//        GarbageRecyclingOrder garbageRecyclingOrder = new GarbageRecyclingOrder();
        startPage();
        List<GarbageRecyclingOrder> list = garbageRecyclingOrderService.selectGarbageRecyclingOrderList(garbageRecyclingOrder);
        return getDataTable(list);
    }
    /**
     * 获取垃圾回收订单详细信息
     */
    @ApiOperation(value = "获取垃圾回收订单详细信息",notes = "获取单条数据")
    @ApiImplicitParam(name = "orderid", value = "订单编号", required = true, dataType = "Long")
    @GetMapping(value = "/{orderid}")
    public AjaxResult getInfo(@PathVariable("orderid") Long orderid)
    {
        return AjaxResult.success(garbageRecyclingOrderService.selectGarbageRecyclingOrderById(orderid));
    }

    /**
     * 新增垃圾回收订单
     */
    @ApiOperation(value = "新增垃圾回收订单", httpMethod = "POST")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "garbageRecyclingOrder", value = "新增垃圾回收订单", required = true, dataType = "GarbageRecyclingOrder"),
    })
    @Log(title = "垃圾回收订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated(GarbageRecyclingOrder.class)GarbageRecyclingOrder garbageRecyclingOrder)
    {
        return toAjax(garbageRecyclingOrderService.insertGarbageRecyclingOrder(garbageRecyclingOrder));
    }

    /**
     * 修改垃圾回收订单
     */

    @ApiOperation(value = "修改垃圾回收订单",notes = "修改垃圾回收订单并实现相关业务")
    @ApiImplicitParam(name = "garbageRecyclingOrder", value = "垃圾回收订单详细表", required = true, dataType = "GarbageRecyclingOrder")
    @Log(title = "垃圾回收订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(GarbageRecyclingOrder garbageRecyclingOrder)
    {
        return toAjax(garbageRecyclingOrderService.updateGarbageRecyclingOrder(garbageRecyclingOrder));
    }

    /**
     * 删除垃圾回收订单
     */
    @ApiOperation(value = "删除垃圾回收订单",notes = "删除垃圾回收订单并实现相关业务")
    @ApiImplicitParam(name = "orderids", value = "订单编号", required = false, dataType = "Long[]")
    @Log(title = "垃圾回收订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderids}")
    public AjaxResult remove(@PathVariable Long[] orderids)
    {
        return toAjax(garbageRecyclingOrderService.deleteGarbageRecyclingOrderByIds(orderids));
    }
}
